home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / weblibev / weblibvc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-02  |  11.2 KB  |  300 lines

  1.  
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // Copyright 1995 by Potomac Software, Inc. Use of this material is subject to
  4. // the terms and conditions of the software license agreement.
  5.  
  6. #ifndef __WEBLIBVC_H__
  7. #define __WEBLIBVC_H__
  8.  
  9. #ifndef WEBLIB_NO_MFC
  10. #include <afxwin.h>  
  11. #endif
  12. #include "weblib.h"
  13. #include "dispatvc.h"
  14.  
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // Browser classes.
  17. //
  18. // The CWeblibBrowserAPI class is a simple C++ wrapper around the API.
  19.  
  20. class CWeblibBrowserAPI
  21.   public:
  22.       CWeblibBrowserAPI();
  23.       CWeblibBrowserAPI(WORD wOptions);
  24.       virtual ~CWeblibBrowserAPI();
  25.       
  26.       BOOL IsGood() const;
  27.  
  28.     BOOL ConnectBrowser(WORD wOptions = WL_POSTMESSAGE | WL_STARTBROWSER);
  29.     BOOL DisconnectBrowser(BOOL bExit = TRUE);
  30.  
  31.     BOOL GetWindowInfo(DWORD dwWindow,LPSTR lpszURL,int cbURL,LPSTR lpszTitle,int cbTitle) const;
  32.     DWORD ListWindows(BOOL bFirst) const;
  33.  
  34.     DWORD ActivateWindow(DWORD dwWindow) const;    
  35.     BOOL CloseWindow(DWORD dwWindow) const;
  36.     
  37.     BOOL SetWindowPos(DWORD dwWindow,DWORD dwX,DWORD dwY,DWORD dwWidth,DWORD dwHeight) const;
  38.     BOOL ShowWindow(DWORD dwWindow,UINT nShow) const;
  39.     
  40.     virtual DWORD ShowFile(LPCSTR lpszFile,LPCSTR lpszMIMEType,DWORD dwWindow,LPCSTR lpszURL,
  41.         HWND hwndNotify,UINT nMsg) const;
  42.         
  43.     virtual DWORD OpenURL(LPCSTR lpszURL,DWORD dwWindow,WORD wOptions,
  44.         HWND hwndNotify,UINT nMsg) const;
  45.     virtual DWORD SaveURL(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,WORD wOptions,
  46.         HWND hwndNotify,UINT nMsg) const;
  47.  
  48.     virtual DWORD PostFormData(LPCSTR lpszURL,DWORD dwWindow,LPCSTR lpszFormData,LPCSTR lpszMIMEType,
  49.         HWND hwndNotify,UINT nMsg) const;
  50.     virtual DWORD SaveFormData(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,LPCSTR lpszFormData,
  51.         LPCSTR lpszMIMEType,HWND hwndNotify,UINT nMsg) const;
  52.             
  53.     BOOL Cancel(DWORD dwTransaction) const;
  54.         
  55.     virtual BOOL RegisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify,UINT nMsg) const;
  56.     virtual BOOL UnregisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify) const;
  57.     
  58.     virtual BOOL RegisterURLEcho(HWND hwndNotify,UINT nMsg) const;
  59.     virtual BOOL UnregisterURLEcho(HWND hwndNotify) const;
  60.     
  61.     virtual BOOL RegisterViewer(LPCSTR lpszMIMEType,WORD wOptions,HWND hwndNotify,UINT nMsg) const;
  62.     virtual BOOL UnregisterViewer(LPCSTR lpszMIMEType,HWND hwndNotify) const;
  63.     
  64.     virtual BOOL RegisterWindowChange(DWORD dwWindow,HWND hwndNotify,UINT nMsg) const;
  65.     virtual BOOL UnregisterWindowChange(DWORD dwWindow,HWND hwndNotify) const;
  66.     
  67.     LPCSTR ParseAnchor(LPCSTR lpszAbsoluteURL,LPCSTR lpszRelativeURL) const;
  68.     DWORD GetVersion(WORD wMajor,WORD wMinor) const;
  69.     
  70.     LPCSTR QueryURLFile(LPCSTR lpszFile) const;        // Netscape only!
  71.     
  72.     BOOL SetNotifyMethod(WORD wMethod) const;    
  73.     DWORD GetTransactionWindow(DWORD dwTransaction) const;
  74.     
  75.   protected:
  76.       HBROWSER GetBrowserHandle() const
  77.           { return m_hBrowser; }
  78.  
  79.   private:
  80.     HBROWSER m_hBrowser;
  81. };
  82.  
  83. ///////////////////////////////////////////////////////////////////////////////
  84. // If just want to use the above CWeblibBrowserAPI base class w/o MFC, then define
  85. // WEBLIB_NO_MFC in your project (for non-MSVC C++ compilers and class libraries).
  86.  
  87. #ifndef WEBLIB_NO_MFC
  88.  
  89. ///////////////////////////////////////////////////////////////////////////////
  90. // The CWeblibBrowser derived class handles browser event notification automatically,
  91. // invoking the proper virtual event handler method when an event is received. To use,
  92. // derive your own class from CWeblibBrowser and override the notification handlers.
  93.  
  94. class CWeblibBrowser : public CWeblibBrowserAPI, public CWeblibDispatch
  95. {
  96.   public:
  97.       CWeblibBrowser();   
  98.       CWeblibBrowser(WORD wOptions);
  99.       virtual ~CWeblibBrowser();
  100.       
  101.       BOOL IsGood() const;
  102.       
  103.       ///////////////////////////////////////////////////////////////////////////
  104.     // New public methods intended to supplant all base class methods that take
  105.     // a notification window and message (notifications are sent to internal window).
  106.  
  107.     DWORD ShowFile(LPCSTR lpszFile,LPCSTR lpszMIMEType,DWORD dwWindow,LPCSTR lpszURL,
  108.         BOOL bNotify = TRUE) const;
  109.         
  110.     DWORD OpenURL(LPCSTR lpszURL,DWORD dwWindow,WORD wOptions,
  111.         BOOL bNotify = TRUE) const;
  112.     DWORD SaveURL(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,WORD wOptions,
  113.         BOOL bNotify = TRUE) const;
  114.  
  115.     DWORD PostFormData(LPCSTR lpszURL,DWORD dwWindow,LPCSTR lpszFormData,
  116.         LPCSTR lpszMIMEType,BOOL bNotify = TRUE) const;
  117.     DWORD SaveFormData(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,LPCSTR lpszFormData,
  118.         LPCSTR lpszMIMEType,BOOL bNotify = TRUE) const;
  119.             
  120.     BOOL RegisterProtocol(LPCSTR lpszProtocol) const;
  121.     BOOL UnregisterProtocol(LPCSTR lpszProtocol) const;
  122.     
  123.     BOOL RegisterURLEcho() const;
  124.     BOOL UnregisterURLEcho() const;
  125.     
  126.     BOOL RegisterViewer(LPCSTR lpszMIMEType,WORD wOptions) const;
  127.     BOOL UnregisterViewer(LPCSTR lpszMIMEType) const;
  128.     
  129.     BOOL RegisterWindowChange(DWORD dwWindow) const;
  130.     BOOL UnregisterWindowChange(DWORD dwWindow) const;
  131.     
  132.     ///////////////////////////////////////////////////////////////////////////
  133.     // Notification event handlers (override in your CWeblibBrowser-derived class).
  134.     
  135.     virtual void OnBeginProgress(DWORD dwTransaction,LPCSTR lpszProgress);
  136.     virtual void OnSetProgressRange(DWORD dwTransaction,DWORD dwMaximum);
  137.     virtual void OnMakingProgress(DWORD dwTransaction,DWORD dwProgress,LPCSTR lpszProgress);
  138.     virtual void OnEndProgress(DWORD dwTransaction);
  139.     
  140.     virtual void OnFinished(DWORD dwTransaction,DWORD dwWindow);
  141.     virtual void OnCanceled(DWORD dwTransaction);
  142.     
  143.     virtual void OnURLEcho(DWORD dwWindow,LPCSTR lpszURL,LPCSTR lpszMIME,LPCSTR lpszReferrer);
  144.         
  145.     virtual void OnOpenURL(DWORD dwTransaction,DWORD dwWindow,DWORD dwFlags,
  146.         LPCSTR lpszURL,LPCSTR lpszMIME,LPCSTR lpszSaveFile,LPCSTR lpszFormData);
  147.             
  148.     virtual void OnWindowChange(DWORD dwWindow,DWORD dwFlags,DWORD dwX,DWORD dwY,
  149.         DWORD dwWidth,DWORD dwHeight);
  150.         
  151.     virtual void OnQueryViewer(LPCSTR lpszURL,LPCSTR lpszMIME,LPSTR lpszFile,UINT cbFile);
  152.         
  153.     virtual void OnViewDocFile(DWORD dwWindow,LPCSTR lpszURL,LPCSTR lpszMIME,LPCSTR lpszFile);
  154.         
  155.     ///////////////////////////////////////////////////////////////////////////
  156.     // Internal window passes notification messages to Dispatch() method.
  157.         
  158.       virtual LRESULT Dispatch(UINT nMsg,WPARAM wParam,LPARAM lParam);
  159.     
  160.   private:
  161.   
  162.     ///////////////////////////////////////////////////////////////////////////
  163.     // Override public base class methods that take a notification window as 
  164.     // private (i.e., unavailable) since notifications are now sent to m_pWnd.
  165.     
  166.      virtual DWORD ShowFile(LPCSTR lpszFile,LPCSTR lpszMIMEType,DWORD dwWindow,LPCSTR lpszURL,
  167.         HWND hwndNotify,UINT nMsg) const;
  168.         
  169.     virtual DWORD OpenURL(LPCSTR lpszURL,DWORD dwWindow,WORD wOptions,
  170.         HWND hwndNotify,UINT nMsg) const;
  171.     virtual DWORD SaveURL(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,WORD wOptions,
  172.         HWND hwndNotify,UINT nMsg) const;
  173.  
  174.     virtual DWORD PostFormData(LPCSTR lpszURL,DWORD dwWindow,LPCSTR lpszFormData,LPCSTR lpszMIMEType,
  175.         HWND hwndNotify,UINT nMsg) const;
  176.     virtual DWORD SaveFormData(LPCSTR lpszURL,LPCSTR lpszFile,DWORD dwWindow,LPCSTR lpszFormData,
  177.         LPCSTR lpszMIMEType,HWND hwndNotify,UINT nMsg) const;
  178.             
  179.     virtual BOOL RegisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify,UINT nMsg) const;
  180.     virtual BOOL UnregisterProtocol(LPCSTR lpszProtocol,HWND hwndNotify) const;
  181.     
  182.     virtual BOOL RegisterURLEcho(HWND hwndNotify,UINT nMsg) const;
  183.     virtual BOOL UnregisterURLEcho(HWND hwndNotify) const;
  184.     
  185.     virtual BOOL RegisterViewer(LPCSTR lpszMIMEType,WORD wOptions,HWND hwndNotify,UINT nMsg) const;
  186.     virtual BOOL UnregisterViewer(LPCSTR lpszMIMEType,HWND hwndNotify) const;
  187.     
  188.     virtual BOOL RegisterWindowChange(DWORD dwWindow,HWND hwndNotify,UINT nMsg) const;
  189.     virtual BOOL UnregisterWindowChange(DWORD dwWindow,HWND hwndNotify) const;
  190.     
  191.     CWnd *m_pWnd;
  192. };
  193.  
  194. #endif    // WEBLIB_NO_MFC
  195.  
  196. ///////////////////////////////////////////////////////////////////////////////
  197. // Toolbar classes.
  198. //
  199. // The CWeblibToolbarAPI class is a simple C++ wrapper around the API.
  200.  
  201. class CWeblibToolbarAPI
  202. {
  203.   public:
  204.       CWeblibToolbarAPI();
  205.       CWeblibToolbarAPI(LPCSTR lpszMenu,HWND hwndNotify,UINT nMsg);
  206.       virtual ~CWeblibToolbarAPI();
  207.       
  208.       BOOL IsGood() const;
  209.  
  210.     virtual BOOL CreateToolbar(LPCSTR lpszMenu,HWND hwndNotify,UINT nMsg);
  211.     BOOL DeleteToolbar();
  212.     
  213.     BOOL IsToolbarActive() const;
  214.     BOOL SetActiveToolbar() const;
  215.     
  216.     BOOL AddToolbarButton(UINT nID,int nIdx,LPCSTR lpszText,HINSTANCE hInstance,
  217.         LPCSTR lpszBitmap,LPCSTR lpszBitmapSel,LPCSTR lpszBitmapFocus,
  218.             LPCSTR lpszBitmapDisabled) const;
  219.     BOOL RemoveToolbarButton(UINT nID) const;  
  220.     
  221.     BOOL IsToolbarButtonVisible(UINT nID) const;
  222.     BOOL ShowToolbarButton(UINT nID,BOOL bShow) const;
  223.     
  224.     BOOL EnableToolbarButton(UINT nID,BOOL bEnable) const;
  225.     BOOL IsToolbarButtonEnabled(UINT nID) const;
  226.     
  227.     LPCSTR GetToolbarText(UINT nID) const;
  228.     BOOL SetToolbarText(UINT nID,LPCSTR lpszText) const;
  229.     
  230.     HFONT GetToolbarFont(WORD wType) const;
  231.     BOOL SetToolbarFont(WORD wType,HFONT hFont) const;
  232.     
  233.     COLORREF GetToolbarBkgnd() const;
  234.     BOOL SetToolbarBkgnd(COLORREF crBackground) const;
  235.     
  236.     COLORREF GetToolbarTextColor(WORD wType) const;
  237.     BOOL SetToolbarTextColor(WORD wType,COLORREF crText) const;
  238.     
  239.   protected:
  240.     HTOOLBAR GetToolbarHandle() const
  241.         { return m_hToolbar; }
  242.  
  243.   private:
  244.     HTOOLBAR m_hToolbar;
  245. };
  246.  
  247. ///////////////////////////////////////////////////////////////////////////////
  248. // If just want to use the above CWeblibToolbarAPI base class w/o MFC, then define
  249. // WEBLIB_NO_MFC in your project (for non-MSVC C++ compilers and class libraries).
  250.  
  251. #ifndef WEBLIB_NO_MFC
  252.  
  253. ///////////////////////////////////////////////////////////////////////////////
  254. // The CWeblibToolbar derived class handles button click notification via a
  255. // virtual event handler method. To use, derive your own class from CWeblibToolbarAPI
  256. // and override the button click notification handler.
  257.  
  258. class CWeblibToolbar : public CWeblibToolbarAPI, public CWeblibDispatch
  259. {
  260.   public:
  261.       CWeblibToolbar();   
  262.       CWeblibToolbar(LPCSTR lpszMenu);
  263.       virtual ~CWeblibToolbar();
  264.       
  265.       BOOL IsGood() const;
  266.       
  267.       ///////////////////////////////////////////////////////////////////////////
  268.     // New public methods intended to supplant all base class methods that take
  269.     // a notification window and message (notifications are now sent to m_pWnd).
  270.     
  271.     BOOL CreateToolbar(LPCSTR lpszMenu);
  272.     
  273.     ///////////////////////////////////////////////////////////////////////////
  274.     // Notification event handlers (override in your CWeblibToolbar-derived class).    
  275.     
  276.     virtual void OnButtonClicked(UINT nButtonID);
  277.     
  278.     ///////////////////////////////////////////////////////////////////////////
  279.     // Internal window passes notification messages to Dispatch() method.
  280.         
  281.       virtual LRESULT Dispatch(UINT nMsg,WPARAM wParam,LPARAM lParam);
  282.         
  283.   private:
  284.   
  285.       ///////////////////////////////////////////////////////////////////////////
  286.     // Override public base class methods that take a notification window as 
  287.     // private (i.e., unavailable) since notifications are sent to internal window.
  288.     
  289.     virtual BOOL CreateToolbar(LPCSTR lpszMenu,HWND hwndNotify,UINT nMsg);
  290.     
  291.     CWnd *m_pWnd;
  292. };
  293.  
  294. #endif        // WEBLIB_NO_MFC
  295.  
  296. #include "weblibvc.inl"
  297.  
  298. #endif        // __WEBLIBVC_H__
  299.